﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RooHui.Infrastructure.Entities.Repository;

namespace RooHui.Infrastructure.Entities.Entity
{
    public class ProcessStepDoing : IAccessible<P_ProcessStepDoing, ProcessStepDoing>, ILogicEntity<P_ProcessStepDoing, ProcessStepDoing>
    {
        public int ID { get; set; }
        public int Type { get; set; }
        public int ProjectID { get; set; }
        public string StepName { get; set; }
        public int CurrentProcessID { get; set; }
        public int PreviousProcessID { get; set; }
        public int NextProcessID { get; set; }

        public ProcessDoing CurrentProcess { get; set; }
        public ProcessDoing NextProcess { get; set; }

        public ProcessStepDoing LoadCurrentProcess(P_ProcessDoing p_processDoing)
        {
            this.CurrentProcess = new ProcessDoing().Set(p_processDoing);
            return this;
        }

        public ProcessStepDoing LoadNextProcess(P_ProcessDoing p_processDoing)
        {
            this.NextProcess = new ProcessDoing().Set(p_processDoing);
            return this;
        }

        protected override void Covariant(P_ProcessStepDoing model)
        {
            if (model != null)
            {
                this.CurrentProcessID = model.CurrentProcessID;
                this.ID = model.ID;
                this.NextProcessID = model.NextProcessID;
                this.PreviousProcessID = model.PreviousProcessID;
                this.ProjectID = model.ProjectID;
                this.Type = model.Type;
                this.StepName = model.StepName;
            }
        }

        protected override P_ProcessStepDoing Inverter(ProcessStepDoing model)
        {
            if (model != null)
            {
                return new P_ProcessStepDoing()
                {
                    CurrentProcessID = model.CurrentProcessID,
                    ID = model.ID,
                    NextProcessID = model.NextProcessID,
                    PreviousProcessID = model.PreviousProcessID,
                    ProjectID = model.ProjectID,
                    Type = model.Type,
                    StepName = model.StepName
                };
            }
            return null;
        }

        public ProcessStepDoing Set(P_ProcessStepDoing dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
